//初始化过程
var Web3 = require('web3');
var util = require('ethereumjs-util')
if (typeof web3 !== 'undefined') {
  web3 = new Web3(web3.currentProvider);
} else {
  // set the provider you want from Web3.providers
  web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
}
//console.log(web3.eth.accounts.create();)
var message = "xyz"
web3.eth.personal.unlockAccount("0x10a5fa2fFF03438941F262A660B4cD073524C205","123456").then(function(){
	//var hasmsg = web3.utils.sha3('\u0019Ethereum Signed Message:\n' + message.length.toString()+message)
	//var hasmsg = '0x' +web3.utils.sha3(message)
	//var hasmsg  = util.hashPersonalMessage(new Buffer(message))
	//console.log(hasmsg)
	var result = web3.eth.sign(message,"0x10a5fa2fFF03438941F262A660B4cD073524C205",function(err,res){
		console.log(err)
		console.log(res)//0x7e30a2b9147796ead481ce26a1c35285aa302b51cb1cca8f1ba466600e2ce5a85993a1ce75f6e54f49f32738bc45cdf7db7626eb24ce994464ef8d18adbb78681c
	}); 
});
//0x5cfc88a2b0756733210daf014b121fccb2694b6d33dd86d0c982a4aa833844774b921ce85d24d7d94c0bd78659a79b459f23a260e627f9a8f098ad8e08860abd1b
//0xea547449c0710196599f6d1967dba4298acee87745004409553ce29353d783da07afefbdc39f869e7869b9c7ae3d577848d0da03389c536cd8ef638fb8776b891b"

//web3.eth.personal.newAccount('123456')
//.then(console.log);
//0x7f7d8e7f7045636a1c954dd19d83b0f045141e31159de1a9a4d85b9c86882abd1d7517f34a1c15ee4da1faf9a898a97667a4567647dc729b4adcc052be8f0ed41b